package xiangmu2;

import java.util.ArrayList;
import java.util.List;

import xiangmu2.Static;

public class rukou {

	public static void main(String[] args) {
		int inputChick = 50;
		int inputdays = 34;

		Egg egg = new Egg(0, 0);
		Chick chick = new Chick(inputChick, 0);
		List<Static> list = new ArrayList<Static>();
		list.add(new Static(chick, egg, 0));

		// System.out.println("first day:"+list);
		for (int i = 1; i <= inputdays; i++) {

			int items = list.size();

			for (int k = 0; k < items; k++) {

				list.get(k).setDay(i);

				if (list.get(k).getChick().getChicknumber() > 0) {
					int chicklife = list.get(k).getChick().getLife();
					list.get(k).getChick().setLife(chicklife + 1);

				}
				if (list.get(k).getChick().getLife() == 22) {

					list.get(k).setChick(new Chick(0,0));
				

				}
				if (list.get(k).getEgg().geteggnumber() > 0) {
					int egglife = list.get(k).getEgg().getLife();
					list.get(k).getEgg().setLife(egglife + 1);

				}

				if (list.get(k).getChick().getLife() > 0 && list.get(k).getChick().getLife() % 5 == 0) {
					int chicknumber = list.get(k).getChick().getChicknumber();
					list.add(new Static(new Chick(0, 0), new Egg(3 * chicknumber, 0), i));

				}
				if (list.get(k).getEgg().getLife() > 0 && list.get(k).getEgg().getLife() % 7 == 0) {

					int eggnumber = list.get(k).getEgg().geteggnumber();
					list.add(new Static(new Chick(eggnumber, 0), new Egg(0, 0), i));
					list.get(k).setEgg(new Egg(0, 0));

				}

			}

			System.out.println("after " + i + " days:\n" + list + "\n");
			
					
			
		}
		
		
		int chickAll = 0, eggAll = 0;
		for (int n = 0; n < list.size(); n++) {
				
			chickAll += list.get(n).getChick().getChicknumber();
			eggAll += list.get(n).getEgg().geteggnumber();
		}

		
		System.out.println("result:\n\n"+
		
			"inputChick= "+inputChick+"\n"+
			"inputdays= "+inputdays+"\n"+
			"chickAll= "+chickAll+"\n"+
			"eggAll= "+eggAll+"\n"	
				
				);
		

	}

}
